<template>
	<view class="pageBox">
		<view class="list">
			<view class="listItem" v-for="item in list" :key="item.id">
				<view class="top flex-between">
					<view class="topL">
						申请时间
					</view>
					<view class="topR">
						{{ item.status == 0 ? "充值中" : item.status == 1 ? "充值成功" : item.status == -1 ? "充值失败" : "" }}
					</view>
				</view>

				<view class="center flex-between">
					<view class="centerL">
						{{ item.createdAt }}
					</view>
					<view :class="[item.status == -1 ? 'centerR centerGrey' : item.status == 0 ? 'centerR centerBlack' : item.status == 1 ? 'centerR centerRed' : '']">
						{{ item.money }}
					</view>
				</view>

				<view class="bom" v-if="item.status == -1">
					拒绝原因：{{ item.reason }}
				</view>
			</view>
		</view>
		<uni-load-more :status="listStatus"></uni-load-more>
	</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [],
				form: {
					page: 1,
					lastId: 0,
				},
				loading: false,
				finished: false,
			}
		},
		onShow() {
			this.list = [];
			this.form.page = 1;
			this.form.lastId = 0;
			this.loading = false;
			this.finished = false;
			this.getList();
		},
		onReachBottom() {
			this.getList();
		},
		computed: {
			listStatus() {
				if (this.finished) return "noMore";
				if (this.loading) return "loading";
				return "more";
			}
		},
		methods: {
			getList() {
				if (this.loading || this.finished) return;
				this.loading = true;
				this.$post({
					module: 'Pay',
					interface: '7002',
					data: {
						type: 1,
						...this.form,
					},
				}).then(res => {
					this.list = this.list.concat(res.list);
					this.form.page = res.currentPage + 1;
					this.form.lastId = res.lastId;
					if (this.form.page > res.lastPage) {
						this.finished = true;
					}
					this.loading = false;
				}).catch(() => {
					this.loading = false;
				})
			},
		},
	}
</script>

<style scoped lang="scss">
	.pageBox {
		padding: 0 32rpx;

		.list {
			.listItem {
				border-bottom: 2rpx solid #EBEDF0;
				padding: 64rpx 0;

				.top {
					.topL {
						font-size: 28rpx;
						font-family: PingFangSC-Regular, PingFang SC;
						font-weight: 400;
						color: #000000;
						line-height: 40rpx;
					}

					.topR {
						font-size: 28rpx;
						font-family: PingFangSC-Regular, PingFang SC;
						font-weight: 400;
						color: #afa9b0;
						line-height: 40rpx;
					}
				}

				.center {
					margin-top: 32rpx;

					.centerL {
						font-size: 28rpx;
						font-family: PingFangSC-Regular, PingFang SC;
						font-weight: 400;
						color: #000000;
						line-height: 40rpx;
					}

					.centerR {
						font-size: 36rpx;
						font-family: DINAlternate-Bold, DINAlternate;
						font-weight: bold;

						line-height: 40rpx;
					}

					.centerGrey {
						color: #afa9b0;
					}

					.centerBlack {
						color: #000000;
					}

					.centerRed {
						color: #FE2E1C;
					}
				}

				.bom {
					font-size: 28rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #afa9b0;
					line-height: 40rpx;
					margin-top: 32rpx;
				}
			}
		}
	}
</style>
